package com.wenqiner.requesttool.view;

import com.wenqiner.requesttool.MainApplication;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.stage.Stage;

import java.io.IOException;

/**
 * @author ranhaifeng
 */
public class MainController {
    @FXML
    protected void innerRequestEvent(ActionEvent event) throws IOException {
        // 创建新的stage
        Stage secondStage = new Stage();
        FXMLLoader fxmlLoader = new FXMLLoader(MainApplication.class.getResource("innerRequest.fxml"));
        Scene scene = new Scene(fxmlLoader.load());
        secondStage.setScene(scene);
        secondStage.setTitle("内部请求");

        InnerRequestController controller = fxmlLoader.getController();
        controller.init();
        secondStage.show();
    }

    @FXML
    protected void outerRequestEvent(ActionEvent event) throws IOException {
        // 创建新的stage
        Stage secondStage = new Stage();
        FXMLLoader fxmlLoader = new FXMLLoader(MainApplication.class.getResource("outerRequest.fxml"));
        Scene scene = new Scene(fxmlLoader.load());
        secondStage.setScene(scene);
        secondStage.setTitle("三方请求");
        OuterRequestController controller = fxmlLoader.getController();
        controller.init();
        secondStage.show();
    }

    @FXML
    protected void grooveRequestEvent(ActionEvent event) throws IOException {
        // 创建新的stage
        Stage secondStage = new Stage();
        FXMLLoader fxmlLoader = new FXMLLoader(MainApplication.class.getResource("grooveRequest.fxml"));
        Scene scene = new Scene(fxmlLoader.load());
        secondStage.setScene(scene);
        secondStage.setTitle("常规请求");
        GrooveRequestController controller = fxmlLoader.getController();
        controller.init();
        secondStage.show();
    }

    @FXML
    protected void parallelInnerEvent(ActionEvent event) throws IOException {
        // 创建新的stage
        Stage secondStage = new Stage();
        FXMLLoader fxmlLoader = new FXMLLoader(MainApplication.class.getResource("parallelInnerRequest.fxml"));
        Scene scene = new Scene(fxmlLoader.load());
        secondStage.setScene(scene);
        secondStage.setTitle("内部请求(并发)");
        ParallelInnerRequestController controller = fxmlLoader.getController();
        controller.init();
        scene.getStylesheets().add(this.getClass().getClassLoader().getResource("copyable-text.css").toExternalForm());
        secondStage.show();
    }

    @FXML
    protected void parallelOuterEvent(ActionEvent event) throws IOException {
        // 创建新的stage
        Stage secondStage = new Stage();
        FXMLLoader fxmlLoader = new FXMLLoader(MainApplication.class.getResource("parallelOuterRequest.fxml"));
        Scene scene = new Scene(fxmlLoader.load());
        secondStage.setScene(scene);
        secondStage.setTitle("三方请求(并发)");
        ParallelOuterRequestController controller = fxmlLoader.getController();
        controller.init();
        scene.getStylesheets().add(this.getClass().getClassLoader().getResource("copyable-text.css").toExternalForm());
        secondStage.show();
    }

    @FXML
    protected void parallelGrooveEvent(ActionEvent event) throws IOException {
        // 创建新的stage
        Stage secondStage = new Stage();
        FXMLLoader fxmlLoader = new FXMLLoader(MainApplication.class.getResource("parallelGrooveRequest.fxml"));
        Scene scene = new Scene(fxmlLoader.load());
        secondStage.setScene(scene);
        secondStage.setTitle("常规请求(并发)");
        ParallelGrooveRequestController controller = fxmlLoader.getController();
        controller.init();
        scene.getStylesheets().add(this.getClass().getClassLoader().getResource("copyable-text.css").toExternalForm());
        secondStage.show();
    }

    @FXML
    protected void httpConfiguration(ActionEvent event) throws IOException {
        // 创建新的stage
        Stage secondStage = new Stage();
        FXMLLoader fxmlLoader = new FXMLLoader(MainApplication.class.getResource("httpConfiguration.fxml"));
        Scene scene = new Scene(fxmlLoader.load());
        secondStage.setScene(scene);
        secondStage.setTitle("http配置");
        HttpConfigurationController controller = fxmlLoader.getController();
        secondStage.show();
    }
}